package com.yang.thread.state;

/**
 * @author yds
 * @program thread-study
 * @description 作为线程礼让 礼让不一定成功 线程执行取决于cpu
 * @create 2020-09-23 12:10
 **/
public class ThreadYield implements Runnable{
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+"开始执行");
        Thread.yield();
        System.out.println(Thread.currentThread().getName()+"结束");
    }

    public static void main(String[] args) {
        ThreadYield t1=new ThreadYield();
        new Thread(t1,"a").start();
        new Thread(t1,"b").start();
    }
}